<template>
	<div class="factory-income table-theme">
		<head-title title="数据--收入明细"></head-title>
		<el-card>
			<div class="top-menu">
				<div class="menu-right">
					<refresh-button @refresh="refreshPage"></refresh-button>
					<search-view :option="searchOption" @value="goSearch" @clear="refreshPage" ></search-view>
				</div>
			</div>
			<p class="data-number">总数据数：{{total}}</p>
			<el-table :data="incomeList" border class="factory-table">
				<el-table-column label="序号" align="center" prop="factory_money_datail_id"></el-table-column>
				<el-table-column label="订单编号" align="center" prop="order_sn"></el-table-column>
				<el-table-column label="利润" align="center" prop="money"></el-table-column>
				<el-table-column label="备注" align="center" prop="brief"></el-table-column>
				<el-table-column label="日期" align="center" prop="add_time"></el-table-column>
			</el-table>
			<div class="pages"><el-pagination background layout="prev, pager, next, jumper" :total="total" @current-change="init" :current-page="page"></el-pagination></div>
		</el-card>
	</div>
</template>

<script>
export default {
	data() {
		return {
			factory_sn: localStorage.getItem('factory_sn'),
			incomeList: [],
			total: 0,
			totalData: 0, 
			page: 0,
			searchOption: [
				{
					value: 0,
					label: "订单号",
				}
			],
			classSelect: 0,
			selectContent: "",
		};
	},
	methods: {
		// 初始化列表
		init(e) {
			this.page = e;
			let data = {
				page: e - 1 ? e - 1 : 0,
				limit: 10,
				factory_sn: this.factory_sn
			};
			if(this.classSelect == 0 && this.selectContent != ''){
				data.order_sn = this.selectContent;
			}
			this.$http(this.$ApiList.FactoryProfitList, data).then(res => {
				this.incomeList = res.datas.list;
				this.total = res.datas.count;
			});
		},
		goSearch(classSelect, selectContent) {
			this.classSelect = classSelect;
			this.selectContent = selectContent;
			this.init();
		},
		refreshPage(){
			this.selectContent = ''
			this.page = 1;
			this.init()
		}
	},
	created() {
		this.init();
	}
};
</script>
<style lang="scss" scoped>
.menu-right{
	flex: 1;
}
</style>
